<template>
    <transition name="modal">
        <div class="modal-mask">
            <div class="modal-wrapper">
                <div class="modal-container">
    
                    <div class="modal-header">
                        <div class="row">
                            <div class="col-lg-12">
                                <h3>操作记录</h3>
                            </div>
                            
                        </div>
                        
                        <button type="button" class="close" @click="$emit('close')">
                            <i class="fa fa-times"></i>
                        </button>
                    </div>
    
                    <div class="modal-body">
                        
                        <div class="list-box">
                            <div class="row m-b">
                                <div class="col-lg-1"><b>序号</b></div>
                                <div class="col-lg-2"><b>更改前状态</b></div>
                                <div class="col-lg-2"><b>更改后状态</b></div>
                                <div class="col-lg-1"><b>操作</b></div>
                                <div class="col-lg-2"><b>操作人</b></div>
                                <div class="col-lg-3"><b>操作时间</b></div>
                                <div class="col-lg-1"><b>备注</b></div>
                            </div>
                            <template v-for="(log,i) in log_list">
                                <div class="row m-b" :key="i">
                                    <div class="col-lg-1">{{i+1}}</div>
                                    <div class="col-lg-2">{{log.before_state | statusStr}}</div>
                                    <div class="col-lg-2">{{log.after_state | statusStr}}</div>
                                    <div class="col-lg-1">{{log.action_name}}</div>
                                    <div class="col-lg-2">{{log.operator}}</div>
                                    <div class="col-lg-3">{{log.addtime}}</div>
                                    <div class="col-lg-1">{{log.remark}}</div>
                                </div>
                            </template>
                        </div>
                        
                    </div>
    
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" @click="$emit('close')">
                        关闭
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </transition>
</template>
<script>
import {tip,ajax} from '../tools/tools.js'

export default {
    name: 'LogModal',
    data() {
        return {
            log_list:[]
        }
    },
    props:{
        sample:{
            type:Object,
            default:{}
        }
    },
    watch:{
        sample:{
            deep:true,
            handler(v,ov){
                var self = this;
                if(v.sample_hash){
                    self.getTransferRecord();
                }
            }
        }
    },
    filters:{
        statusStr(v){
            var sObj = {
                '0':'待分配',
                '1':'待分析',
                '2':'待审核',
                '3':'人工检测完成',
                '4':'全部检测完成',
                '5':'交付完成',
                '9':'审核不通过',
                '10':'被驳回'
            }

            return sObj[v];
        }
    },
    methods: {
        getTransferRecord(){
            var self = this;
            ajax.getTransferRecord({
                param:{
                    sample_hash:self.sample.sample_hash
                },
                cb(data){
                    self.log_list = data.data;
                }
            })
        }
    },
    mounted() {
    }
}
</script>
<style scoped>
.list-box{
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px;
}

.close {
    position: absolute;
    right: 30px;
    top: 30px;
}

.modal-mask {
    position: fixed;
    z-index: 10001;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-color: rgba(0, 0, 0, .5);
    transition: opacity .3s ease;
}

.modal-wrapper {
    position: absolute;
    width: 100%;
    height: 1px;
    left: 0;
    right:0;
    top: 120px;
}

.modal-container {
    width: 950px;
    margin: 0px auto;
    padding: 20px 30px;
    background-color: #fff;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
    transition: all .3s ease;
    font-family: Helvetica, Arial, sans-serif;
    position: relative;
}

.modal-header h3 {
    margin-top: 0;
    color: #42b983;
}

.modal-default-button {
    float: right;
}

.modal-enter {
    opacity: 0;
}

.modal-leave-active {
    opacity: 0;
}

.modal-enter .modal-container,
.modal-leave-active .modal-container {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
}
</style>
